home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 March / Chip_2002-03_cd1.bin / zkuste / delphi / kolekce / d3456 / gmprintsuite_eval.exe / {app} / GmObjects.pas < prev    next >
Pascal/Delphi Source File  |  2002-01-02  |  35KB  |  1,174 lines

  1. unit GmObjects;
  2.  
  3. interface
  4.  
  5. uses Windows, GmStream, Classes, Graphics, GmTypes;
  6.  
  7. type
  8.   TGmBaseObject = class(TObject)
  9.   private
  10.     FShapeID: integer;
  11.     FX: Integer;
  12.     FY: Integer;
  13.     FPreviewPage: integer;
  14.   public
  15.     constructor Create;
  16.     destructor Destroy; override;
  17.     procedure SaveToStream(AStream: TStream); virtual;
  18.     procedure LoadFromStream(AStream: TStream); virtual;
  19.     procedure Draw(ACanvas: TCanvas; APreview: TComponent; Offset: TPoint; Scale: Extended); virtual; abstract; //; Ppi: integer; Offset: TPoint; FPreview: TComponent); virtual; abstract;
  20.     // properties...
  21.     property X: Integer read FX write FX;
  22.     property Y: Integer read FY write FY;
  23.     property ShapeID: integer read FShapeID;
  24.     property Page: integer read FPreviewPage write FPreviewPage;
  25.   end;
  26.  
  27.   TGmGraphicObject = class (TGmBaseObject)
  28.   private
  29.     FCopyMode: TCopyMode;
  30.     FDrawAsBitmap: Boolean;
  31.     FX2: Integer;
  32.     FY2: Integer;
  33.     FBitmapStream: TMemoryStream;
  34.     FMetaFile: TMetaFile;
  35.     FType: TGmGraphicType;
  36.     function GetBitmap: TBitmap;
  37.     procedure SetBitmap(ABitmap: TBitmap);
  38.   public
  39.     constructor Create;
  40.     destructor Destroy; override;
  41.     procedure Draw(ACanvas: TCanvas; APreview: TComponent; Offset: TPoint; Scale: Extended); override;
  42.     procedure SaveToStream(AStream: TStream); override;
  43.     procedure LoadFromStream(AStream: TStream); override;
  44.     procedure SetBounds(aX1, aY1, aX2, aY2: Extended);
  45.     property CopyMode: TCopyMode read FCopyMode write FCopyMode;
  46.     property X2: Integer read FX2 write FX2;
  47.     property Y2: Integer read FY2 write FY2;
  48.     property DrawAsBitmap: Boolean read FDrawAsBitmap write FDrawAsBitmap;
  49.     property Bitmap: TBitmap read GetBitmap write SetBitmap;
  50.     property Metafile: TMetafile read FMetafile write FMetafile;
  51.     property AType: TGmGraphicType read FType write FType;
  52.   end;
  53.  
  54.   // *** TGmLineObject ***
  55.   TGmLineType = (GmLine, GmLineExt);
  56.  
  57.   TGmLineObject = class(TGmBaseObject)
  58.   private
  59.     FPen: TGmPen;
  60.     FX2 : Integer;
  61.     FY2 : Integer;
  62.     FLineType: TGmLineType;
  63.   public
  64.     constructor Create;
  65.     procedure LoadFromStream(AStream: TStream); override;
  66.     procedure SaveToStream(AStream: TStream); override;
  67.     procedure Draw(ACanvas: TCanvas; APreview: TComponent; Offset: TPoint; Scale: Extended); override;
  68.     //procedure SetBounds(aX1, aY1, aX2, aY2: Extended);
  69.     property X2: Integer read FX2 write FX2;
  70.     property Y2: Integer read FY2 write FY2;
  71.     property Pen: TGmPen read FPen write FPen;
  72.     property LineType: TGmLineType read FLineType write FLineType default GmLine;
  73.   end;
  74.  
  75.   TGmTextObject = class(TGmBaseObject)
  76.   private
  77.     FBrush: TGmBrush;
  78.     FCaption: string;
  79.     FFont: TGmFont;
  80.   public
  81.     constructor Create;
  82.     procedure SaveToStream(AStream: TStream); override;
  83.     procedure LoadFromStream(AStream: TStream); override;
  84.     procedure Draw(ACanvas: TCanvas; APreview: TComponent; Offset: TPoint; Scale: Extended); override;
  85.     // properties...
  86.     property Brush: TGmBrush read FBrush write FBrush;
  87.     property Caption: string read FCaption write FCaption;
  88.     property Font: TGmFont read FFont write FFont;
  89.   end;
  90.  
  91.   // *** TGmTextBoxObject ***
  92.  
  93.   TGmTextBoxObject = class(TGmTextObject)
  94.   private
  95.     FAlignment: TAlignment;
  96.     FVertAlignment: byte;
  97.     FX2: Integer;
  98.     FY2: Integer;
  99.     FPen: TGmPen;
  100.   public
  101.     constructor Create;
  102.     procedure Draw(ACanvas: TCanvas; APreview: TComponent; Offset: TPoint; Scale: Extended); override;
  103.     procedure SaveToStream(AStream: TStream); override;
  104.     procedure LoadFromStream(AStream: TStream); override;
  105.     //procedure SetBounds(Left, Top, Right, Bottom: Integer);
  106.     property Alignment: TAlignment read FAlignment write FAlignment;
  107.     property VertAlignment: byte read FVertAlignment write FVertAlignment;
  108.     property X2: Integer read FX2 write FX2;
  109.     property Y2: Integer read FY2 write FY2;
  110.     property Pen: TGmPen read FPen write FPen;
  111.   end;
  112.  
  113.   TGmSimpleShape = class(TGmBaseObject)
  114.   private
  115.     FBrush: TGmBrush;
  116.     FPen: TGmPen;
  117.     FX2, FY2: integer;
  118.   public
  119.     procedure SaveToStream(AStream: TStream); override;
  120.     procedure LoadFromStream(AStream: TStream); override;
  121.     // properties...
  122.     property Brush: TGmBrush read FBrush write FBrush;
  123.     property Pen: TGmPen read FPen write FPen;
  124.     property X2: integer read FX2 write FX2;
  125.     property Y2: integer read FY2 write FY2;
  126.   end;
  127.  
  128.   TGmEllipseShape = class(TGmSimpleShape)
  129.   public
  130.     constructor Create;
  131.     procedure Draw(ACanvas: TCanvas; APreview: TComponent; Offset: TPoint; Scale: Extended); override;
  132.   end;
  133.  
  134.   TGmRectangleShape = class(TGmSimpleShape)
  135.   public
  136.     RectType: TGmRectType;
  137.     constructor Create;
  138.     procedure Draw(ACanvas: TCanvas; APreview: TComponent; Offset: TPoint; Scale: Extended); override;
  139.   end;
  140.  
  141.   TGmRoundRectShape = class(TGmSimpleShape)
  142.   private
  143.     FX3: Integer;
  144.     FY3: Integer;
  145.   public
  146.     constructor Create;
  147.     procedure SaveToStream(AStream: TStream); override;
  148.     procedure LoadFromStream(AStream: TStream); override;
  149.     procedure Draw(ACanvas: TCanvas; APreview: TComponent; Offset: TPoint; Scale: Extended); override;
  150.     property X3: Integer read FX3 write FX3;
  151.     property Y3: Integer read FY3 write FY3;
  152.   end;
  153.  
  154.   TGmComplexShape = class(TGmSimpleShape)
  155.   private
  156.     FX3: Integer;
  157.     FY3: Integer;
  158.     FX4: Integer;
  159.     FY4: Integer;
  160.   public
  161.     procedure LoadFromStream(AStream: TStream); override;
  162.     procedure SaveToStream(AStream: TStream); override;
  163.     //procedure SetBounds(aX1, aY1, aX2, aY2, aX3, aY3, aX4, aY4: Extended);
  164.     // properties...
  165.     property X3: Integer read FX3 write FX3;
  166.     property Y3: Integer read FY3 write FY3;
  167.     property X4: Integer read FX4 write FX4;
  168.     property Y4: Integer read FY4 write FY4;
  169.   end;
  170.  
  171.   TGmArcShape = class(TGmComplexShape)
  172.   public
  173.     constructor Create;
  174.     procedure Draw(ACanvas: TCanvas; APreview: TComponent; Offset: TPoint; Scale: Extended); override;
  175.   end;
  176.  
  177.   TGmChordShape = class(TGmComplexShape)
  178.   public
  179.     constructor Create;
  180.     procedure Draw(ACanvas: TCanvas; APreview: TComponent; Offset: TPoint; Scale: Extended); override;
  181.   end;
  182.  
  183.   TGmPieShape = class(TGmComplexShape)
  184.   public
  185.     constructor Create;
  186.     procedure Draw(ACanvas: TCanvas; APreview: TComponent; Offset: TPoint; Scale: Extended); override;
  187.   end;
  188.  
  189.   {$IFNDEF VER100}
  190.  
  191.   TGmPolyBaseObject = class(TGmBaseObject)
  192.   private
  193.     FBrush: TGmBrush;
  194.     FPen: TGmPen;
  195.   public
  196.     Points: array of TPoint;
  197.     procedure SaveToStream(AStream: TStream); override;
  198.     procedure LoadFromStream(AStream: TStream); override;
  199.     property Pen: TGmPen read FPen write FPen;
  200.     property Brush: TGmBrush read FBrush write FBrush;
  201.   end;
  202.  
  203.   TGmPolygonObject = class(TGmPolyBaseObject)
  204.   public
  205.     constructor Create;
  206.     procedure Draw(ACanvas: TCanvas; APreview: TComponent; Offset: TPoint; Scale: Extended); override;
  207.   end;
  208.  
  209.   TGmPolyLineObject = class(TGmPolyBaseObject)
  210.   public
  211.     constructor Create;
  212.     procedure Draw(ACanvas: TCanvas; APreview: TComponent; Offset: TPoint; Scale: Extended); override;
  213.   end;
  214.  
  215.   TGmPolyBezierObject = class(TGmPolyBaseObject)
  216.   public
  217.     constructor Create;
  218.     procedure Draw(ACanvas: TCanvas; APreview: TComponent; Offset: TPoint; Scale: Extended); override;
  219.   end;
  220.  
  221.   {$ENDIF}
  222.  
  223.  
  224.   // *** Global Functions ***
  225.  
  226.   function BrushToGmBrush(ABrush: TBrush): TGmBrush;
  227.   function FontToGmFont(AFont: TFont): TGmFont;
  228.   function PenToGmPen(APen: TPen): TGmPen;
  229.   procedure GmBrushToBrush(ABrush: TBrush; AGmBrush: TGmBrush);
  230.   procedure GmFontToFont(AFont: TFont; AGmFont: TGmFont; Scale: Extended);
  231.   procedure GmPenToPen(APen: TPen; AGmPen: TGmPen);
  232.  
  233. implementation
  234.  
  235. uses GmConst, GmPreview;
  236.  
  237. //------------------------------------------------------------------------------
  238.  
  239. // *** Global functions ***
  240.  
  241. function BrushToGmBrush(ABrush: TBrush): TGmBrush;
  242. begin
  243.   Result.Color  := ABrush.Color;
  244.   Result.Style  := ABrush.Style;
  245. end;
  246.  
  247. function FontToGmFont(AFont: TFont): TGmFont;
  248. var
  249.   logRec : TLogFont;
  250. begin
  251.   GetObject(AFont.Handle, SizeOf(TLogFont), @logrec);
  252.   Result.Angle  := logrec.lfEscapement / 10;
  253.   Result.Color  := AFont.Color;
  254.   Result.Name   := AFont.Name;
  255.   Result.Size   := AFont.Size;
  256.   Result.Style  := AFont.Style;
  257. end;
  258.  
  259. function PenToGmPen(APen: TPen): TGmPen;
  260. begin
  261.   Result.Color := APen.Color;
  262.   Result.Style := APen.Style;
  263.   Result.Width := APen.Width;
  264.   Result.Mode  := APen.mode;
  265. end;
  266.  
  267. procedure GmBrushToBrush(ABrush: TBrush; AGmBrush: TGmBrush);
  268. begin
  269.   ABrush.Color  := AGmBrush.Color;
  270.   ABrush.Style  := AGmBrush.Style;
  271. end;
  272.  
  273. procedure GmFontToFont(AFont: TFont; AGmFont: TGmFont; Scale: Extended);
  274. var
  275.   logRec : TLogFont;
  276. begin
  277.   AFont.Color         := AGmFont.Color;
  278.   AFont.Name          := AGmFont.Name;
  279.   AFont.Size          := AGmFont.Size;
  280.   AFont.Style         := AGmFont.Style;
  281.   AFont.Height        := Round(Scale * AFont.Height);
  282.   GetObject(AFont.Handle, SizeOf(TLogFont), @logrec);
  283.   logrec.lfEscapement := Round(AGmFont.Angle*10);
  284.   AFont.Handle := CreateFontIndirect(logRec);
  285. end;
  286.  
  287. procedure GmPenToPen(APen: TPen; AGmPen: TGmPen);
  288. begin
  289.   APen.Color := AGmPen.Color;
  290.   APen.Style := AGmPen.Style;
  291.   APen.Width := AGmPen.Width;
  292.   APen.Mode  := AGmPen.Mode;
  293. end;
  294.  
  295. function PixelsPerInch(ACanvas: TCanvas): integer;
  296. begin
  297.   Result := GetDeviceCaps(ACanvas.Handle, LOGPIXELSX);
  298. end;
  299.  
  300. //------------------------------------------------------------------------------
  301.  
  302. // *** TGmBaseObject ***
  303.  
  304. constructor TGmBaseObject.Create;
  305. begin
  306.   inherited Create;
  307. end;
  308.  
  309. destructor TGmBaseObject.Destroy;
  310. begin
  311.   inherited Destroy;
  312. end;
  313.  
  314. procedure TGmBaseObject.SaveToStream(AStream: TStream);
  315. var
  316.   GmStream: TGmExtStream;
  317. begin
  318.   AStream.WriteBuffer(FShapeID, SizeOf(FShapeID));
  319.   GmStream := TGmExtStream.Create;
  320.   try
  321.     GmStream.WriteInteger(FX);
  322.     GmStream.WriteInteger(FY);
  323.   finally
  324.     GmStream.SaveToStream(AStream);
  325.     GmStream.Free;
  326.   end;
  327. end;
  328.  
  329. procedure TGmBaseObject.LoadFromStream(AStream: TStream);
  330. var
  331.   GmStream: TGmExtStream;
  332. begin
  333.   GmStream := TGmExtStream.Create;
  334.   try
  335.     GmStream.LoadFromStream(AStream);
  336.     FX := GmStream.ReadInteger;
  337.     FY := GmStream.ReadInteger;
  338.   finally
  339.     GmStream.Free;
  340.   end;
  341. end;
  342.  
  343. //------------------------------------------------------------------------------
  344.  
  345. // *** TGmGraphicObject ***
  346.  
  347. constructor TGmGraphicObject.Create;
  348. begin
  349.   inherited Create;
  350.   FShapeID := GM_GRAPHIC_ID;
  351.   FDrawAsBitmap := False;
  352.   FBitmapStream := TMemoryStream.Create;
  353. end;
  354.  
  355. destructor TGmGraphicObject.Destroy;
  356. begin
  357.   if Assigned(FBitmapStream) then FBitmapStream.Free;
  358.   if Assigned(FMetafile) then FMetafile.Free;
  359.   inherited;
  360. end;
  361.  
  362. function TGmGraphicObject.GetBitmap: TBitmap;
  363. begin
  364.   Result := TBitmap.Create;
  365.   if FBitmapStream.Size > 0 then
  366.   begin
  367.     FBitmapStream.Seek(0, soFromBeginning);
  368.     Result.LoadFromStream(FBitmapStream);
  369.   end
  370. end;
  371.  
  372. procedure TGmGraphicObject.SetBitmap(ABitmap: TBitmap);
  373. begin
  374.   FBitmapStream.Clear;
  375.   ABitmap.SaveToStream(FBitmapStream);
  376.   FType := gtBitmap;
  377. end;
  378.  
  379. procedure TGmGraphicObject.Draw(ACanvas: TCanvas; APreview: TComponent; Offset: TPoint; Scale: Extended);
  380.  
  381. procedure PrintBitmap(Canvas: TCanvas; DestRect: TRect; Bitmap: TBitmap);
  382. var
  383.   BitmapHeader: pBitmapInfo;
  384.   BitmapImage : POINTER;
  385.   HeaderSize : DWORD; // Use DWORD for D3-D5 compatibility
  386.   ImageSize : DWORD;
  387.   CM : LongInt;
  388. begin
  389.   CM := 0;
  390.   case FCopyMode of
  391.     cmBlackness:  CM := BLACKNESS;
  392.     cmDstInvert:  CM := DSTINVERT;
  393.     cmMergeCopy:  CM := MERGECOPY;
  394.     cmMergePaint: CM := MERGEPAINT;
  395.     cmNotSrcCopy: CM := NOTSRCCOPY;
  396.     cmNotSrcErase:CM := NOTSRCERASE;
  397.     cmPatCopy:    CM := PATCOPY;
  398.     cmPatInvert:  CM := PATINVERT;
  399.     cmPatPaint:   CM := PATPAINT;
  400.     cmSrcAnd:     CM := SRCAND;
  401.     cmSrcCopy:    CM := SRCCOPY;
  402.     cmSrcErase:   CM := SRCERASE;
  403.     cmSrcInvert:  CM := SRCINVERT;
  404.     cmSrcPaint:   CM := SRCPAINT;
  405.     cmWhiteness:  CM := WHITENESS;
  406.   end;
  407.  
  408.   GetDIBSizes(Bitmap.Handle, HeaderSize, ImageSize);
  409.   GetMem(BitmapHeader, HeaderSize);
  410.   GetMem(BitmapImage, ImageSize);
  411.   try
  412.     GetDIB(Bitmap.Handle, Bitmap.Palette, BitmapHeader^, BitmapImage^);
  413.     StretchDIBits(Canvas.Handle,
  414.                   DestRect.Left, DestRect.Top, // Destination Origin
  415.                   DestRect.Right - DestRect.Left, // Destination Width
  416.                   DestRect.Bottom - DestRect.Top, // Destination Height
  417.                   0, 0, // Source Origin
  418.                   Bitmap.Width, Bitmap.Height, // Source Width & Height
  419.                   BitmapImage,
  420.                   TBitmapInfo(BitmapHeader^),
  421.                   DIB_RGB_COLORS,
  422.                   CM)
  423.   finally
  424.     FreeMem(BitmapHeader);
  425.     FreeMem(BitmapImage)
  426.   end;
  427. end; {PrintBitmap}
  428.  
  429. var
  430.   DestRect: TRect;
  431.   CanvasPpi: integer;
  432.   ABitmap: TBitmap;
  433.   LastCopyMode: TCopyMode;
  434. begin
  435.   CanvasPpi := Round(Scale * PixelsPerInch(ACanvas));
  436.   DestRect := Rect((0-Offset.X) + Round(CanvasPpi * ConvertValue(FX, GmUnits, GmInches)),
  437.                    (0-Offset.Y) + Round(CanvasPpi * ConvertValue(FY, GmUnits, GmInches)),
  438.                    (0-Offset.X) + Round(CanvasPpi * ConvertValue(FX2, GmUnits, GmInches)),
  439.                    (0-Offset.Y) + Round(CanvasPpi * ConvertValue(FY2, GmUnits, GmInches)));
  440.   LastCopyMode := ACanvas.CopyMode;
  441.   ACanvas.CopyMode := FCopyMode;
  442.   try
  443.     case FType of
  444.       gtBitmap  :
  445.       begin
  446.         if TGmPreview(APreview).GmPrinter.Printing then
  447.           PrintBitmap(ACanvas, DestRect, GetBitmap)
  448.         else
  449.           ACanvas.StretchDraw(DestRect, GetBitmap);
  450.       end;
  451.       gtMetafile:
  452.       begin
  453.         if (FDrawAsBitmap) and (TGmPreview(APreview).GmPrinter.Printing) then
  454.         begin
  455.           ABitmap := TBitmap.Create;
  456.           ABitmap.Width :=  (DestRect.Right - DestRect.Left);
  457.           ABitmap.Height := (DestRect.Bottom - DestRect.Top);
  458.           ABitmap.HandleType := bmDIB;
  459.           PlayEnhMetaFile(ABitmap.Canvas.Handle, FMetaFile.Handle, Rect(0,0,ABitmap.Width, ABitmap.Height));
  460.           PrintBitmap(ACanvas, DestRect, ABitmap);
  461.           ABitmap.Free;
  462.         end
  463.         else
  464.           PlayEnhMetaFile(ACanvas.Handle, FMetaFile.Handle, DestRect);
  465.       end;
  466.     end;
  467.   finally
  468.     ACanvas.CopyMode := LastCopyMode;
  469.   end;
  470. end;
  471.  
  472. procedure TGmGraphicObject.LoadFromStream(AStream: TStream);
  473. var
  474.   GmStream: TGmExtStream;
  475.   ABitmap: TBitmap;
  476. begin
  477.   inherited LoadFromStream(AStream);
  478.   GmStream := TGmExtStream.Create;
  479.   try
  480.  
  481.     GmStream.LoadFromStream(AStream);
  482.     FX2 := GmStream.ReadInteger;
  483.     FY2 := GmStream.ReadInteger;
  484.     FDrawAsBitmap := GmStream.ReadBoolean;
  485.     FType := TGmGraphicType(GmStream.ReadInteger);
  486.     case FType of
  487.       gtMetafile:
  488.       begin
  489.         Metafile := TMetafile.Create;
  490.         Metafile.LoadFromStream(GmStream);
  491.       end;
  492.       gtBitmap  :
  493.       begin
  494.         ABitmap := TBitmap.Create;
  495.         ABitmap.LoadFromStream(GmStream);
  496.         Bitmap := (ABitmap);
  497.         ABitmap.Free;
  498.       end;
  499.     end;
  500.   finally
  501.     GmStream.Free;
  502.   end;
  503. end;
  504.  
  505. procedure TGmGraphicObject.SaveToStream(AStream: TStream);
  506. var
  507.   GmStream: TGmExtStream;
  508. begin
  509.   inherited SaveToStream(AStream);
  510.   GmStream := TGmExtStream.Create;
  511.   try
  512.     GmStream.WriteInteger(FX2);
  513.     GmStream.WriteInteger(FY2);
  514.     GmStream.WriteBoolean(FDrawAsBitmap);
  515.     GmStream.WriteInteger(Ord(FType));
  516.     case FType of
  517.       gtMetafile: Metafile.SaveToStream(GmStream);
  518.       gtBitmap  : Bitmap.SaveToStream(GmStream);
  519.     end;
  520.   finally
  521.     GmStream.SaveToStream(AStream);
  522.     GmStream.Free;
  523.   end;
  524. end;
  525.  
  526. procedure TGmGraphicObject.SetBounds(aX1, aY1, aX2, aY2: Extended);
  527. begin
  528.   FX  := Round(aX1);
  529.   FY  := Round(aY1);
  530.   FX2 := Round(aX2);
  531.   FY2 := Round(aY2);
  532. end;
  533.  
  534. //------------------------------------------------------------------------------
  535.  
  536. // *** TGmLineObject ***
  537.  
  538. constructor TGmLineObject.Create;
  539. begin
  540.   inherited Create;
  541.   FShapeID := GM_LINE_ID;
  542.   FLineType:= GmLine;
  543. end;
  544.  
  545. procedure TGmLineObject.LoadFromStream(AStream: TStream);
  546. var
  547.   GmStream: TGmExtStream;
  548. begin
  549.   inherited LoadFromStream(AStream);
  550.   GmStream := TGmExtStream.Create;
  551.   try
  552.     GmStream.LoadFromStream(AStream);
  553.     FPen      := GmStream.ReadPen;
  554.     FX2       := GmStream.ReadInteger;
  555.     FY2       := GmStream.ReadInteger;
  556.     FLineType := TGmLineType(GmStream.ReadInteger);
  557.   finally
  558.     GmStream.Free;
  559.   end;
  560. end;
  561.  
  562. procedure TGmLineObject.SaveToStream(AStream: TStream);
  563. var
  564.   GmStream: TGmExtStream;
  565. begin
  566.   inherited SaveToStream(AStream);
  567.   GmStream := TGmExtStream.Create;
  568.   try
  569.     GmStream.WritePen(FPen);
  570.     GmStream.WriteInteger(FX2);
  571.     GmStream.WriteInteger(FY2);
  572.     GmStream.WriteInteger(Ord(FLineType));
  573.   finally
  574.     GmStream.SaveToStream(AStream);
  575.     GmStream.Free;
  576.   end;
  577. end;
  578.  
  579. procedure TGmLineObject.Draw(ACanvas: TCanvas; APreview: TComponent; Offset: TPoint; Scale: Extended);
  580. var
  581.   CanvasPpi: integer;
  582. begin
  583.   CanvasPpi := Round(Scale * PixelsPerInch(ACanvas));
  584.   with ACanvas do
  585.   begin
  586.     GmPenToPen(Pen, FPen);
  587.     MoveTo((0-Offset.X) + Round(CanvasPpi * ConvertValue(FX, GmUnits, GmInches)),
  588.            (0-Offset.Y) + Round(CanvasPpi * ConvertValue(FY, GmUnits, GmInches)));
  589.     LineTo((0-Offset.X) + Round(CanvasPpi * ConvertValue(FX2, GmUnits, GmInches)),
  590.            (0-Offset.Y) + Round(CanvasPpi * ConvertValue(FY2, GmUnits, GmInches)));
  591.   end;
  592. end;
  593.  
  594. //------------------------------------------------------------------------------
  595.  
  596.  
  597. // *** TGmTextObject ***
  598.  
  599. constructor TGmTextObject.Create;
  600. begin
  601.   inherited Create;
  602.   FShapeID := GM_TEXT_ID;
  603. end;
  604.  
  605. procedure TGmTextObject.SaveToStream(AStream: TStream);
  606. var
  607.   GmStream: TGmExtStream;
  608. begin
  609.   inherited SaveToStream(AStream);
  610.   GmStream := TGmExtStream.Create;
  611.   try
  612.     GmStream.WriteBrush(FBrush);
  613.     GmStream.WriteStr(FCaption);
  614.     GmStream.WriteFont(FFont);
  615.   finally
  616.     GmStream.SaveToStream(AStream);
  617.     GmStream.Free;
  618.   end;
  619. end;
  620.  
  621. procedure TGmTextObject.LoadFromStream(AStream: TStream);
  622. var
  623.   GmStream: TGmExtStream;
  624. begin
  625.   inherited LoadFromStream(AStream);
  626.   GmStream := TGmExtStream.Create;
  627.   try
  628.     GmStream.LoadFromStream(AStream);
  629.     FBrush    := GmStream.ReadBrush;
  630.     FCaption  := GmStream.ReadStr;
  631.     FFont     := GmStream.ReadFont;
  632.   finally
  633.     GmStream.Free;
  634.   end;
  635. end;
  636.  
  637. procedure TGmTextObject.Draw(ACanvas: TCanvas; APreview: TComponent; Offset: TPoint; Scale: Extended);
  638. var
  639.   Top, Left: integer;
  640.   Tokenized: string;
  641.   CanvasPpi: integer;
  642. begin
  643.   CanvasPpi := Round(Scale * PixelsPerInch(ACanvas));
  644.   Tokenized := TGmPreview(APreview).Tokenize(FCaption, FPreviewPage);
  645.   Left  := (0-Offset.X) + Round(CanvasPpi * ConvertValue(X, GmUnits, GmInches));
  646.   Top   := (0-Offset.Y) + Round(CanvasPpi * ConvertValue(Y, GmUnits, GmInches));
  647.   GmBrushToBrush(ACanvas.Brush, FBrush);
  648.   GmFontToFont(ACanvas.Font, FFont, Scale);
  649.   //ACanvas.Font.Height := Round(Scale*ACanvas.Font.Height);
  650.   ACanvas.TextOut(Left, Top, Tokenized);
  651. end;
  652.  
  653. //------------------------------------------------------------------------------
  654.  
  655. constructor TGmTextBoxObject.Create;
  656. begin
  657.   inherited Create;
  658.   FShapeID := GM_TEXTBOX_ID;
  659. end;
  660.  
  661. procedure TGmTextBoxObject.Draw(ACanvas: TCanvas; APreview: TComponent; Offset: TPoint; Scale: Extended);
  662. var
  663.   DestRect: TRect;
  664.   Align: Byte;
  665.   VertAlign: Byte;
  666.   CanvasPpi: integer;
  667. begin
  668.   Align := 0;
  669.   VertAlign := 0;
  670.   CanvasPpi := Round(Scale * PixelsPerInch(ACanvas));
  671.  
  672.   case FAlignment of
  673.     taLeftJustify : Align := DT_LEFT;
  674.     taCenter      : Align := DT_CENTER;
  675.     taRightJustify: Align := DT_RIGHT;
  676.   end;
  677.   case FVertAlignment of
  678.     0   : VertAlign := DT_TOP;
  679.     1   : VertAlign := DT_VCENTER+DT_SINGLELINE;
  680.     2   : VertAlign := DT_BOTTOM+DT_SINGLELINE;
  681.   end;
  682.  
  683.   with ACanvas do
  684.   begin
  685.     GmBrushToBrush(Brush, FBrush);
  686.     GmFontToFont(Font, FFont, Scale);
  687.     GmPenToPen(Pen, FPen);
  688.     // calculate the destination rectangle...
  689.  
  690.     DestRect.Left   := (0-Offset.X) + Round(CanvasPpi * ConvertValue(FX, GmUnits, GmInches));
  691.     DestRect.Top    := (0-Offset.Y) + Round(CanvasPpi * ConvertValue(FY, GmUnits, GmInches));
  692.     DestRect.Right  := (0-Offset.X) + Round(CanvasPpi * ConvertValue(FX2, GmUnits, GmInches));
  693.     DestRect.Bottom := (0-Offset.Y) + Round(CanvasPpi * ConvertValue(FY2, GmUnits, GmInches));
  694.  
  695.     Rectangle(DestRect.Left, DestRect.Top, DestRect.Right, DestRect.Bottom);
  696.     Brush.Style := bsClear;
  697.  
  698.     Windows.DrawText(Handle,
  699.                      PChar(FCaption),
  700.                      Length(FCaption),
  701.                      DestRect,
  702.                      DT_WORDBREAK+Align+VertAlign+DT_EXPANDTABS);
  703.   end;
  704. end;
  705.  
  706. procedure TGmTextBoxObject.SaveToStream(AStream: TStream);
  707. var
  708.   GmStream: TGmExtStream;
  709. begin
  710.   inherited SaveToStream(AStream);
  711.   GmStream := TGmExtStream.Create;
  712.   try
  713.     GmStream.WriteInteger(Ord(FAlignment));
  714.     GmStream.WriteInteger(FX2);
  715.     GmStream.WriteInteger(FY2);
  716.     GmStream.WritePen(FPen);
  717.   finally
  718.     GmStream.SaveToStream(AStream);
  719.     GmStream.Free;
  720.   end;
  721. end;
  722.  
  723. procedure TGmTextBoxObject.LoadFromStream(AStream: TStream);
  724. var
  725.   GmStream: TGmExtStream;
  726. begin
  727.   inherited LoadFromStream(AStream);
  728.   GmStream := TGmExtStream.Create;
  729.   try
  730.     GmStream.LoadFromStream(AStream);
  731.     FAlignment := TAlignment(GmStream.ReadInteger);
  732.     FX2        := GmStream.ReadInteger;
  733.     FY2        := GmStream.ReadInteger;
  734.     FPen       := GmStream.ReadPen;
  735.   finally
  736.     GmStream.Free;
  737.   end;
  738. end;
  739.  
  740. //------------------------------------------------------------------------------
  741.  
  742. // *** TGmSimpleShape ***
  743.  
  744. procedure TGmSimpleShape.SaveToStream(AStream: TStream);
  745. var
  746.   GmStream: TGmExtStream;
  747. begin
  748.   inherited SaveToStream(AStream);
  749.   GmStream := TGmExtStream.Create;
  750.   try
  751.     GmStream.WriteBrush(FBrush);
  752.     GmStream.WritePen(FPen);
  753.     GmStream.WriteInteger(FX2);
  754.     GmStream.WriteInteger(FY2);
  755.   finally
  756.     GmStream.SaveToStream(AStream);
  757.     GmStream.Free;
  758.   end;
  759. end;
  760.  
  761. procedure TGmSimpleShape.LoadFromStream(AStream: TStream);
  762. var
  763.   GmStream: TGmExtStream;
  764. begin
  765.   inherited LoadFromStream(AStream);
  766.   GmStream := TGmExtStream.Create;
  767.   try
  768.     GmStream.LoadFromStream(AStream);
  769.     FBrush := GmStream.ReadBrush;
  770.     FPen   := GmStream.ReadPen;
  771.     FX2    := GmStream.ReadInteger;
  772.     FY2    := GmStream.ReadInteger;
  773.   finally
  774.     GmStream.Free;
  775.   end;
  776. end;
  777.  
  778. //------------------------------------------------------------------------------
  779.  
  780. // *** TGmRectangleShape ***
  781.  
  782. constructor TGmRectangleShape.Create;
  783. begin
  784.   inherited Create;
  785.   FShapeID := GM_RECTANGLE_ID;
  786.   RectType := gmRectangle;
  787. end;
  788.  
  789. procedure TGmRectangleShape.Draw(ACanvas: TCanvas; APreview: TComponent; Offset: TPoint; Scale: Extended);
  790. var
  791.   ARect: TRect;
  792.   CanvasPpi: integer;
  793. begin
  794.   CanvasPpi := Round(Scale * PixelsPerInch(ACanvas));
  795.   ARect.Left    := (0-Offset.X) + Round(CanvasPpi * ConvertValue(FX, GmUnits, GmInches));
  796.   ARect.Top     := (0-Offset.Y) + Round(CanvasPpi * ConvertValue(FY, GmUnits, GmInches));
  797.   ARect.Right   := (0-Offset.X) + Round(CanvasPpi * ConvertValue(FX2, GmUnits, GmInches));
  798.   ARect.Bottom  := (0-Offset.Y) + Round(CanvasPpi * ConvertValue(FY2, GmUnits, GmInches));
  799.   GmBrushToBrush(ACanvas.Brush, FBrush);
  800.   GmPenToPen(ACanvas.Pen, FPen);
  801.   case RectType of
  802.     gmRectangle: ACanvas.Rectangle(ARect.Left, ARect.Top, ARect.Right, ARect.Bottom);
  803.     gmFillRect:  ACanvas.FillRect(ARect);
  804.   end;
  805. end;
  806.  
  807. //------------------------------------------------------------------------------
  808.  
  809. // *** TGmEllipseShape ***
  810.  
  811. constructor TGmEllipseShape.Create;
  812. begin
  813.   inherited;
  814.   FShapeID := GM_ELLIPSE_ID;
  815. end;
  816.  
  817. procedure TGmEllipseShape.Draw(ACanvas: TCanvas; APreview: TComponent; Offset: TPoint; Scale: Extended);
  818. var
  819.   ARect: TRect;
  820.   CanvasPpi: integer;
  821. begin
  822.   CanvasPpi := Round(Scale * PixelsPerInch(ACanvas));
  823.   ARect.Left    := (0-Offset.X) + Round(CanvasPpi * ConvertValue(FX, GmUnits, GmInches));
  824.   ARect.Top     := (0-Offset.Y) + Round(CanvasPpi * ConvertValue(FY, GmUnits, GmInches));
  825.   ARect.Right   := (0-Offset.X) + Round(CanvasPpi * ConvertValue(FX2, GmUnits, GmInches));
  826.   ARect.Bottom  := (0-Offset.Y) + Round(CanvasPpi * ConvertValue(FY2, GmUnits, GmInches));
  827.  
  828.   with ACanvas do
  829.   begin
  830.     GmPenToPen(Pen, FPen);
  831.     GmBrushToBrush(Brush, FBrush);
  832.     Ellipse(ARect.Left, ARect.Top, ARect.Right, ARect.Bottom);
  833.   end;
  834. end;
  835.  
  836. //------------------------------------------------------------------------------
  837.  
  838. // *** TGmRoundRectShape ***
  839.  
  840. constructor TGmRoundRectShape.Create;
  841. begin
  842.   inherited;
  843.   FShapeID := GM_ROUNDRECT_ID;
  844. end;
  845.  
  846. procedure TGmRoundRectShape.SaveToStream(AStream: TStream);
  847. var
  848.   GmStream: TGmExtStream;
  849. begin
  850.   inherited SaveToStream(AStream);
  851.   GmStream := TGmExtStream.Create;
  852.   try
  853.     GmStream.WriteInteger(FX3);
  854.     GmStream.WriteInteger(FY3);
  855.   finally
  856.     GmStream.SaveToStream(AStream);
  857.     GmStream.Free;
  858.   end;
  859. end;
  860.  
  861. procedure TGmRoundRectShape.LoadFromStream(AStream: TStream);
  862. var
  863.   GmStream: TGmExtStream;
  864. begin
  865.   inherited LoadFromStream(AStream);
  866.   GmStream := TGmExtStream.Create;
  867.   try
  868.     GmStream.LoadFromStream(AStream);
  869.     FX3 := GmStream.ReadInteger;
  870.     FY3 := GmStream.ReadInteger;
  871.   finally
  872.     GmStream.Free;
  873.   end;
  874. end;
  875.  
  876. procedure TGmRoundRectShape.Draw(ACanvas: TCanvas; APreview: TComponent; Offset: TPoint; Scale: Extended);
  877. var
  878.   ARect: TRect;
  879.   _X3, _Y3: integer;
  880.   CanvasPpi: integer;
  881. begin
  882.   CanvasPpi := Round(Scale * PixelsPerInch(ACanvas));
  883.   ARect.Left    := (0-Offset.X) + Round(CanvasPpi * ConvertValue(FX, GmUnits, GmInches));
  884.   ARect.Top     := (0-Offset.Y) + Round(CanvasPpi * ConvertValue(FY, GmUnits, GmInches));
  885.   ARect.Right   := (0-Offset.X) + Round(CanvasPpi * ConvertValue(FX2, GmUnits, GmInches));
  886.   ARect.Bottom  := (0-Offset.Y) + Round(CanvasPpi * ConvertValue(FY2, GmUnits, GmInches));
  887.   _X3           := (0-Offset.X) + Round(CanvasPpi * ConvertValue(FX3, GmUnits, GmInches));
  888.   _Y3           := (0-Offset.Y) + Round(CanvasPpi * ConvertValue(FY3, GmUnits, GmInches));
  889.  
  890.   with ACanvas do
  891.   begin
  892.     GmPenToPen(Pen, FPen);
  893.     GmBrushToBrush(Brush, FBrush);
  894.     RoundRect(ARect.Left, ARect.Top, ARect.Right, ARect.Bottom, _X3, _Y3);
  895.   end;
  896. end;
  897.  
  898. //------------------------------------------------------------------------------
  899.  
  900. // *** TGmComplexShape ***
  901.  
  902. procedure TGmComplexShape.LoadFromStream(AStream: TStream);
  903. var
  904.   GmStream: TGmExtStream;
  905. begin
  906.   inherited LoadFromStream(AStream);
  907.   GmStream := TGmExtStream.Create;
  908.   try
  909.     GmStream.LoadFromStream(AStream);
  910.     FX3 := GmStream.ReadInteger;
  911.     FY3 := GmStream.ReadInteger;
  912.     FX4 := GmStream.ReadInteger;
  913.     FY4 := GmStream.ReadInteger;
  914.   finally
  915.     GmStream.Free;
  916.   end;
  917. end;
  918.  
  919. procedure TGmComplexShape.SaveToStream(AStream: TStream);
  920. var
  921.   GmStream: TGmExtStream;
  922. begin
  923.   inherited SaveToStream(AStream);
  924.   GmStream := TGmExtStream.Create;
  925.   try
  926.     GmStream.WriteInteger(FX3);
  927.     GmStream.WriteInteger(FY3);
  928.     GmStream.WriteInteger(FX4);
  929.     GmStream.WriteInteger(FY4);
  930.   finally
  931.     GmStream.SaveToStream(AStream);
  932.     GmStream.Free;
  933.   end;
  934. end;
  935.  
  936. //------------------------------------------------------------------------------
  937.  
  938. // *** TGmArcShape ***
  939.  
  940. constructor TGmArcShape.Create;
  941. begin
  942.   inherited Create;
  943.   FShapeID := GM_ARC_ID;
  944. end;
  945.  
  946. procedure TGmArcShape.Draw(ACanvas: TCanvas; APreview: TComponent; Offset: TPoint; Scale: Extended);
  947. var
  948.   CanvasPpi: integer;
  949. begin
  950.   CanvasPpi := Round(Scale * PixelsPerInch(ACanvas));
  951.   with ACanvas do
  952.   begin
  953.     GmPenToPen(Pen, FPen);
  954.     GmBrushToBrush(Brush, FBrush);
  955.     Arc((0-Offset.X) + Round(CanvasPpi * ConvertValue(FX, GmUnits, GmInches)),
  956.         (0-Offset.Y) + Round(CanvasPpi * ConvertValue(FY, GmUnits, GmInches)),
  957.         (0-Offset.X) + Round(CanvasPpi * ConvertValue(FX2, GmUnits, GmInches)),
  958.         (0-Offset.Y) + Round(CanvasPpi * ConvertValue(FY2, GmUnits, GmInches)),
  959.         (0-Offset.X) + Round(CanvasPpi * ConvertValue(FX3, GmUnits, GmInches)),
  960.         (0-Offset.Y) + Round(CanvasPpi * ConvertValue(FY3, GmUnits, GmInches)),
  961.         (0-Offset.X) + Round(CanvasPpi * ConvertValue(FX4, GmUnits, GmInches)),
  962.         (0-Offset.Y) + Round(CanvasPpi * ConvertValue(FY4, GmUnits, GmInches)));
  963.   end;
  964. end;
  965.  
  966. //------------------------------------------------------------------------------
  967.  
  968. // *** TGmChordShape ***
  969.  
  970. constructor TGmChordShape.Create;
  971. begin
  972.   inherited Create;
  973.   FShapeID := GM_CHORD_ID;
  974. end;
  975.  
  976. procedure TGmChordShape.Draw(ACanvas: TCanvas; APreview: TComponent; Offset: TPoint; Scale: Extended);
  977. var
  978.   CanvasPpi: integer;
  979. begin
  980.   CanvasPpi := Round(Scale * PixelsPerInch(ACanvas));
  981.   with ACanvas do
  982.   begin
  983.     GmPenToPen(Pen, FPen);
  984.     GmBrushToBrush(Brush, FBrush);
  985.     Chord((0-Offset.X) + Round(CanvasPpi * ConvertValue(FX, GmUnits, GmInches)),
  986.           (0-Offset.Y) + Round(CanvasPpi * ConvertValue(FY, GmUnits, GmInches)),
  987.           (0-Offset.X) + Round(CanvasPpi * ConvertValue(FX2, GmUnits, GmInches)),
  988.           (0-Offset.Y) + Round(CanvasPpi * ConvertValue(FY2, GmUnits, GmInches)),
  989.           (0-Offset.X) + Round(CanvasPpi * ConvertValue(FX3, GmUnits, GmInches)),
  990.           (0-Offset.Y) + Round(CanvasPpi * ConvertValue(FY3, GmUnits, GmInches)),
  991.           (0-Offset.X) + Round(CanvasPpi * ConvertValue(FX4, GmUnits, GmInches)),
  992.           (0-Offset.Y) + Round(CanvasPpi * ConvertValue(FY4, GmUnits, GmInches)));
  993.   end;
  994. end;
  995.  
  996. //------------------------------------------------------------------------------
  997.  
  998. // *** TGmPieShape ***
  999.  
  1000. constructor TGmPieShape.Create;
  1001. begin
  1002.   inherited Create;
  1003.   FShapeID := GM_PIE_ID;
  1004. end;
  1005.  
  1006. procedure TGmPieShape.Draw(ACanvas: TCanvas; APreview: TComponent; Offset: TPoint; Scale: Extended);
  1007. var
  1008.   CanvasPpi: integer;
  1009. begin
  1010.   CanvasPpi := Round(Scale * PixelsPerInch(ACanvas));
  1011.   with ACanvas do
  1012.   begin
  1013.     GmPenToPen(Pen, FPen);
  1014.     GmBrushToBrush(Brush, FBrush);
  1015.     Pie((0-Offset.X) + Round(CanvasPpi * ConvertValue(FX, GmUnits, GmInches)),
  1016.         (0-Offset.Y) + Round(CanvasPpi * ConvertValue(FY, GmUnits, GmInches)),
  1017.         (0-Offset.X) + Round(CanvasPpi * ConvertValue(FX2, GmUnits, GmInches)),
  1018.         (0-Offset.Y) + Round(CanvasPpi * ConvertValue(FY2, GmUnits, GmInches)),
  1019.         (0-Offset.X) + Round(CanvasPpi * ConvertValue(FX3, GmUnits, GmInches)),
  1020.         (0-Offset.Y) + Round(CanvasPpi * ConvertValue(FY3, GmUnits, GmInches)),
  1021.         (0-Offset.X) + Round(CanvasPpi * ConvertValue(FX4, GmUnits, GmInches)),
  1022.         (0-Offset.Y) + Round(CanvasPpi * ConvertValue(FY4, GmUnits, GmInches)));
  1023.   end;
  1024. end;
  1025.  
  1026.  
  1027. //------------------------------------------------------------------------------
  1028.  
  1029. {$IFNDEF VER100}
  1030.  
  1031. // *** TGmPolyBaseObject ***
  1032.  
  1033. procedure TGmPolyBaseObject.SaveToStream(AStream: TStream);
  1034. var
  1035.   GmStream: TGmExtStream;
  1036.   ICount: integer;
  1037. begin
  1038.   inherited SaveToStream(AStream);
  1039.   GmStream := TGmExtStream.Create;
  1040.   try
  1041.     GmStream.WriteBrush(FBrush);
  1042.     GmStream.WritePen(FPen);
  1043.     GmStream.WriteInteger(High(Points));
  1044.     for ICount := 0 to High(Points) do
  1045.     begin
  1046.       GmStream.WriteInteger(Points[ICount].X);
  1047.       GmStream.WriteInteger(Points[ICount].Y);
  1048.     end;
  1049.   finally
  1050.     GmStream.SaveToStream(AStream);
  1051.     GmStream.Free;
  1052.   end;
  1053. end;
  1054.  
  1055. procedure TGmPolyBaseObject.LoadFromStream(AStream: TStream);
  1056. var
  1057.   GmStream: TGmExtStream;
  1058.   ICount: integer;
  1059. begin
  1060.   inherited LoadFromStream(AStream);
  1061.   GmStream := TGmExtStream.Create;
  1062.   try
  1063.     GmStream.LoadFromStream(AStream);
  1064.     FBrush := GmStream.ReadBrush;
  1065.     FPen   := GmStream.ReadPen;
  1066.     SetLength(Points, GmStream.ReadInteger+1);
  1067.     for ICount := 0 to High(Points) do
  1068.     begin
  1069.       Points[ICount].X := GmStream.ReadInteger;
  1070.       Points[ICount].Y := GmStream.ReadInteger;
  1071.     end;
  1072.   finally
  1073.     GmStream.Free;
  1074.   end;
  1075. end;
  1076.  
  1077. //------------------------------------------------------------------------------
  1078.  
  1079. // *** TPolygonObject ***
  1080.  
  1081. constructor TGmPolygonObject.Create;
  1082. begin
  1083.   inherited Create;
  1084.   FShapeID := GM_POLYGON_ID;
  1085. end;
  1086.  
  1087. procedure TGmPolygonObject.Draw(ACanvas: TCanvas; APreview: TComponent; Offset: TPoint; Scale: Extended);
  1088. var
  1089.   count: integer;
  1090.   CanvasPoints: array of TPoint;
  1091.   CanvasPpi: integer;
  1092. begin
  1093.   with ACanvas do
  1094.   begin
  1095.     CanvasPpi := Round(Scale * PixelsPerInch(ACanvas));
  1096.     GmBrushToBrush(Brush, FBrush);
  1097.     GmPenToPen(Pen, FPen);
  1098.     SetLength(CanvasPoints, High(Points)+1);
  1099.  
  1100.     for count := 0 to High(Points) do
  1101.     begin
  1102.       CanvasPoints[count].x := (0-Offset.X) + Round(CanvasPpi * ConvertValue(Points[count].x, GmUnits, GmInches)); //Round(Ppi * InchesX);
  1103.       CanvasPoints[count].y := (0-Offset.Y) + Round(CanvasPpi * ConvertValue(Points[count].y, GmUnits, GmInches)); // Round(Ppi * InchesY);
  1104.     end;
  1105.     Polygon(CanvasPoints);
  1106.   end;
  1107. end;
  1108.  
  1109. //------------------------------------------------------------------------------
  1110.  
  1111. // *** TPolylineObject ***
  1112.  
  1113. constructor TGmPolyLineObject.Create;
  1114. begin
  1115.   inherited Create;
  1116.   FShapeID := GM_POLYLINE_ID;
  1117. end;
  1118.  
  1119. procedure TGmPolyLineObject.Draw(ACanvas: TCanvas; APreview: TComponent; Offset: TPoint; Scale: Extended);
  1120. var
  1121.   count: integer;
  1122.   CanvasPoints: array of TPoint;
  1123.   CanvasPpi: integer;
  1124. begin
  1125.   with ACanvas do
  1126.   begin
  1127.     CanvasPpi := Round(Scale * PixelsPerInch(ACanvas));
  1128.     GmBrushToBrush(Brush, FBrush);
  1129.     GmPenToPen(Pen, FPen);
  1130.     SetLength(CanvasPoints, High(Points)+1);
  1131.  
  1132.     for count := 0 to High(Points) do
  1133.     begin
  1134.       CanvasPoints[count].x := (0-Offset.X) + Round(CanvasPpi * ConvertValue(Points[count].x, GmUnits, GmInches)); //Round(Ppi * InchesX);
  1135.       CanvasPoints[count].y := (0-Offset.Y) + Round(CanvasPpi * ConvertValue(Points[count].y, GmUnits, GmInches)); // Round(Ppi * InchesY);
  1136.     end;
  1137.     Polyline(CanvasPoints);
  1138.   end;
  1139. end;
  1140.  
  1141. //------------------------------------------------------------------------------
  1142.  
  1143. constructor TGmPolyBezierObject.Create;
  1144. begin
  1145.   inherited;
  1146.   FShapeID := GM_POLYBEZIER_ID;
  1147. end;
  1148.  
  1149. procedure TGmPolyBezierObject.Draw(ACanvas: TCanvas; APreview: TComponent; Offset: TPoint; Scale: Extended);
  1150. var
  1151.   count: integer;
  1152.   CanvasPoints: array of TPoint;
  1153.   CanvasPpi: integer;
  1154. begin
  1155.   with ACanvas do
  1156.   begin
  1157.     CanvasPpi := Round(Scale * PixelsPerInch(ACanvas));
  1158.     GmBrushToBrush(Brush, FBrush);
  1159.     GmPenToPen(Pen, FPen);
  1160.     SetLength(CanvasPoints, High(Points)+1);
  1161.  
  1162.     for count := 0 to High(Points) do
  1163.     begin
  1164.       CanvasPoints[count].x := (0-Offset.X) + Round(CanvasPpi * ConvertValue(Points[count].x, GmUnits, GmInches)); //Round(Ppi * InchesX);
  1165.       CanvasPoints[count].y := (0-Offset.Y) + Round(CanvasPpi * ConvertValue(Points[count].y, GmUnits, GmInches)); // Round(Ppi * InchesY);
  1166.     end;
  1167.     PolyBezier(CanvasPoints);
  1168.   end;
  1169. end;
  1170.  
  1171. {$ENDIF}
  1172.  
  1173. end.
  1174.